package com.wlts.wzy.SelfModule.mamagerController;


import com.baomidou.mybatisplus.extension.service.IService;
import com.github.xiaoymin.knife4j.annotations.ApiSort;
import com.wlts.wzy.Base.*;
import com.wlts.wzy.Result.Result;
import com.wlts.wzy.SelfModule.entity.SelfBrand;
import com.wlts.wzy.SelfModule.entity.SelfGoods;
import com.wlts.wzy.SelfModule.service.ISelfBrandService;
import com.wlts.wzy.api.request.self.PageSelfBrandRequest;
import com.wlts.wzy.expand.MyLambdaQueryWrapper;
import com.wlts.wzy.expand.MyPage;
import com.wlts.wzy.util.StringUtils;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *
 * </p>
 *
 * @author zhiyong
 * @since 2021-03-19
 */
@Api(tags = "自营品牌表 后台管理控制器",position = 10)
@RestController
@RequestMapping("/manager/self-brand")
@ApiSort(value = 10)
public class SelfBrandManagerController extends BaseController<SelfBrand> implements IBaseController<SelfBrand, PageSelfBrandRequest> {
    @Autowired
    private ISelfBrandService selfBrandService;

    @Override
    public IService<SelfBrand> getBaseService() {
        return selfBrandService;
    }

    @Override
    public Result<MyPage<SelfBrand>> getPage(PageSelfBrandRequest basePageParam) {

        MyLambdaQueryWrapper<SelfBrand> wrapper = new MyLambdaQueryWrapper<>();

        if(StringUtils.isNotEmpty(basePageParam.getBrandTitle())){
            wrapper.like(SelfBrand::getBrandTitle,basePageParam.getBrandTitle());
        }

        wrapper.eq(BaseEntity::getDelFlag, "0");


        MyPage<SelfBrand> brandMyPage = selfBrandService.page(wrapper, basePageParam.getCurrentPage(), basePageParam.getPageSize(), true);
        return Result.buildResult(brandMyPage);
    }
}
